//es5
function sum5() {
  let sum = 0;
  Array.prototype.slice.call(arguments).forEach((num) => {
    sum += num * 1;
  });
  return sum;
}

console.log(sum5(1, 2, 3));

//es6
function sum6(...args) {
  return args.reduce((sum, item) => sum + item, 0);
}

console.log(sum6(1, 2, 3, 4));
